(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
"use strict";

loader.define(['pages/config/config'], function (config, require, exports, module, global) {
  var pageview = {};

  pageview.init = function () {
    var userInput = bui.input({
      id: ".user-input",
      callback: function callback(e) {
        // 清空数据
        this.empty();
      }
    }); // 密码不能为空

    var haspwd = function haspwd(pwd) {
      if (pwd == '') return false;
      return true;
    }; // 注册的时候校验只能由8-18位字母或者数字.@_组成


    var pwdcheck = function pwdcheck(pwd) {
      var rule = /^[a-zA-Z0-9.@_]{8,18}$/;

      if (!rule.test(pwd)) {
        return false;
      }

      return true;
    }; // 两次密码相等


    var pwdconfirm = function pwdconfirm(pwd1, pwd2) {
      if (pwd1 != pwd2) return false;
      return true;
    }; // 密码显示或者隐藏


    var password = bui.input({
      id: "#pwdInput",
      iconClass: ".icon-eye",
      onBlur: function onBlur(e) {
        if (!haspwd(e.target.value)) {
          bui.hint("密码不能为空");
        } else if (!pwdcheck(e.target.value)) {
          bui.hint("密码只能由8-18位字母或者数字.@_组成");
        }

        ;
      },
      callback: function callback(e) {
        //切换类型
        this.toggleType(); //

        $(e.target).toggleClass("active");
      }
    });
    var confirmpwd = bui.input({
      id: "#pwdConfirm",
      onBlur: function onBlur(e) {
        var pwd1 = $("#pwd").attr("value");

        if (!pwdconfirm(pwd1, e.target.value)) {
          bui.hint("两次密码不一致");
        }
      }
    });
    var btnSend = $("#btn-send");
    var timer = bui.timer({
      onEnd: function onEnd() {
        btnSend.removeClass("disabled").text("重新获取验证码");
      },
      onProcess: function onProcess(e) {
        var valWithZero = e.count < 10 ? "0" + e.count : e.count;
        btnSend.text(valWithZero + "后重新获取");
      },
      times: 60
    });

    var phonecheck = function phonecheck(phonenum) {
      // 总共11位（第1位：1 第2位：3~9）
      var rule = /^1[3-9]\d{9}$/;
      if (!rule.test(phonenum)) return false;
      return true;
    };

    $("#btn-send").on("click", function (e) {
      var mobile = $("#phonenumber").attr("value");

      if (!phonecheck(mobile)) {
        bui.hint("请输入正确手机号"); // bui.hint({ content: "<i class='icon-check'></i><br />请输入正确手机号", position: "center", effect: "fadeInDown" });
      } else {
        var url_ = config.apiurl + 'api/v1.0/sms_codes/' + mobile;
        bui.ajax({
          // 手机号
          url: url_,
          data: {},
          method: 'get'
        }).then(function (res) {
          console.log(res['errmsg']);
          var msg = res['errmsg'];

          if (msg == "发送成功") {
            var hasDisabled = $(this).hasClass("disabled");

            if (!hasDisabled) {
              $(this).addClass("disabled");
              bui.hint("验证码发送成功");
              timer.restart();
            }
          } else {
            bui.hint("改手机号已注册，请登录");
            bui.load({
              url: "pages/main/main"
            });
          }
        }, function (res, status) {
          console.log(status);
        });
      }
    });
    $("#btn-register1").on("click", function (e) {
      // 短信验证 + 密码确认（还需要吗）
      // 短信验证成功 跳转登陆页面
      // 短信验证失败 验证码清空 或 密码确认清空（还需要吗）
      // 跳转到登陆界面
      var mobile = $("#phonenumber").attr("value");
      var sms_code = $("#check").attr("value");
      var password = $("#pwd").attr("value");
      var password2 = $("#confirmpwd").attr("value");

      if (!haspwd(password) || !pwdcheck(password) || !pwdconfirm(password, password2)) {
        bui.hint("注册失败,请检查密码输入"); // 清空数据

        $("#password").val("");
        $("#confirmpwd").val("");
      } else {
        var data_ = {
          mobile: mobile,
          sms_code: sms_code,
          password: password,
          password2: password2
        };
        data_ = JSON.stringify(data_);
        bui.ajax({
          // url: 相对路径
          url: config.apiurl + "api/v1.0/register",
          data: data_,
          method: "post",
          headers: {
            'Content-Type': 'application/json'
          }
        }).then(function (res) {
          // console.log("hhhh")
          // console.log(res)
          var msg = res['errmsg'];
          console.log(msg);

          if (msg == "注册成功") {
            bui.hint({
              content: "<i class='icon-check'></i><br />注册成功",
              position: "center",
              effect: "fadeInDown"
            });
            bui.load({
              url: "pages/main/main"
            });
          } else {
            bui.hint("注册失败");
          }
        }, function (res, status) {
          console.log("www");
          console.log(status);
        });
      }
    });
  };

  pageview.init();
  return pageview;
});
},{}]},{},[1]);
